<template>
  <div class="date-picker-test">
    <h1>日期选择器本地化测试</h1>
    
    <div class="test-sections">
      <div class="test-section">
        <h2>当前语言设置</h2>
        <ul>
          <li>LocaleStore语言: {{ localeStore.locale }}</li>
          <li>localStorage语言: {{ localStorageLanguage }}</li>
          <li>Element Plus语言: {{ elementPlusLocale }}</li>
        </ul>
      </div>
      
      <div class="test-section">
        <h2>日期选择器测试</h2>
        <el-form :inline="true">
          <el-form-item label="选择日期:">
            <el-date-picker
              v-model="selectedDate"
              type="date"
              placeholder="请选择日期"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              style="width: 200px;"
            />
          </el-form-item>
          
          <el-form-item label="选择日期时间:">
            <el-date-picker
              v-model="selectedDateTime"
              type="datetime"
              placeholder="请选择日期时间"
              format="YYYY-MM-DD HH:mm:ss"
              value-format="YYYY-MM-DD HH:mm:ss"
              style="width: 200px;"
            />
          </el-form-item>
          
          <el-form-item label="选择月份:">
            <el-date-picker
              v-model="selectedMonth"
              type="month"
              placeholder="请选择月份"
              format="YYYY-MM"
              value-format="YYYY-MM"
              style="width: 200px;"
            />
          </el-form-item>
        </el-form>
      </div>
      
      <div class="test-section">
        <h2>选择的值</h2>
        <ul>
          <li>选择的日期: {{ selectedDate || '未选择' }}</li>
          <li>选择的日期时间: {{ selectedDateTime || '未选择' }}</li>
          <li>选择的月份: {{ selectedMonth || '未选择' }}</li>
        </ul>
      </div>
      
      <div class="test-section">
        <h2>其他Element Plus组件测试</h2>
        <el-button @click="showMessage">显示消息</el-button>
        <el-button @click="showConfirm">显示确认框</el-button>
        
        <el-pagination
          v-model:current-page="currentPage"
          :page-size="10"
          :total="100"
          layout="total, prev, pager, next"
          style="margin-top: 20px;"
        />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useLocaleStore } from '@/stores/localeStore'

const localeStore = useLocaleStore()

const selectedDate = ref('')
const selectedDateTime = ref('')
const selectedMonth = ref('')
const currentPage = ref(1)

const localStorageLanguage = ref('')
const elementPlusLocale = ref('')

const showMessage = () => {
  ElMessage.success('这是一条成功消息')
}

const showConfirm = () => {
  ElMessageBox.confirm(
    '此操作将永久删除该文件, 是否继续?',
    '提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  ).then(() => {
    ElMessage.success('删除成功!')
  }).catch(() => {
    ElMessage.info('已取消删除')
  })
}

onMounted(() => {
  localStorageLanguage.value = localStorage.getItem('i18nextLng') || 'null'
  
  // 尝试获取Element Plus的当前语言设置
  try {
    // 这里可能需要根据实际的Element Plus配置来获取
    elementPlusLocale.value = 'zh-cn (通过全局配置)'
  } catch (error) {
    elementPlusLocale.value = '无法获取'
  }
  
  console.log('日期选择器测试页面加载完成')
  console.log('当前语言设置:', localeStore.locale)
  console.log('localStorage语言:', localStorageLanguage.value)
})
</script>

<style scoped>
.date-picker-test {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.test-sections {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.test-section {
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f9f9f9;
}

.test-section h2 {
  margin-bottom: 20px;
  color: #333;
  border-bottom: 2px solid #409EFF;
  padding-bottom: 10px;
}

.test-section ul {
  list-style-type: none;
  padding: 0;
}

.test-section li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.test-section li:last-child {
  border-bottom: none;
}

.el-form {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.el-form-item {
  margin-bottom: 20px;
}
</style>
